﻿/**********************************************************************/
/*                                                                    */
/*                   embDocumentInhalator                             */
/*             http://embdocumentinhalator.codeplex.com/              */
/*                                                                    */
/*               (c) Copyright 2010 Ilija Injac         .             */
/*                                                                    */
/*  This source is subject to the CDDL License                        */
/*  http://embdocumentinhalator.codeplex.com/license                  */
/*                                                                    */
/*                                                                    */
/**********************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.UserCode;
using Microsoft.SharePoint.Security;
using System.Security.Permissions;
using System.Security;
using Microsoft.SharePoint;
using System.Web.Hosting;
using WIA;
using embWIAScan;


namespace embSPScanExpert.Proxy
{

    /// <summary>
    /// This class perfoms the scanning job, inside
    /// the fulltrusted proxy.
    /// </summary>
    /// This element was inserted by injac on machine PLATINCHECKER.
    /// 29.01.2011,20:53
    public class ScanOperation:SPProxyOperation
    {
        /// <summary>
        /// Executes the trusted operation.
        /// </summary>
        /// <param name="args">The args.</param>
        /// <returns></returns>
        /// This element was inserted by injac on machine PLATINCHECKER.
        /// 29.01.2011,20:54
        public override object Execute(SPProxyOperationArgs args)
        {
            if (args != null)
            {
                ScannerArgs arguments = args as ScannerArgs;
                
                //embWIAFlatbedScan flatbedscan = new embWIAFlatbedScan();
                //    arguments.ImageContent =
                //        embScannerProxy.SerializationUtilities.ByteArrayToString(
                //        flatbedscan.ScanFlatbedImageBytes(arguments.ImageFormat, @"f:\test\", "test", 75, 75));

                    embWIAFlatbedScan flatbedscan = new embWIAFlatbedScan();
                    arguments.ImageContent =
                        
                        flatbedscan.ScanToSharePoint(arguments.ScannerName,
                        arguments.ScanResolution,arguments.ImageFormat,arguments.PreferredColorFormat);
                
                return arguments.ImageContent;
            }
            else
            {
                return null;
            }
          
        }

        

    }
}
